<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>君元药店管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="style/admin.css" media="all">
    <link rel="stylesheet" href="style/login.css" media="all">
    <style>
        html, body {
            padding: 0px;
            margin: 0px;
            width：100vw;
            height: 100vh;
            background-repeat: no-repeat;
            background-image: url(images/login-bg.jpg);
        }

        #login-box {
            width: 380px;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
<body>
<div style="height:300px;">
</div>
<div id="login-box" class="layui-card">
    <div class="layui-card-header">君元药店管理系统（连锁版）</div>
    <div class="layui-card-body">
        <div class="layadmin-user-login-box layadmin-user-login-body">
            <form class="layui-form" action="#" lay-filter="login-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                           for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required"
                           placeholder="用户名"
                           class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                           for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                           placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item" style="margin-bottom: 20px;">
                    <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                    <a id="forget-password-btn" href="#" class="layadmin-user-jump-change layadmin-link"
                       style="margin-top: 7px;">忘记密码？</a>
                </div>
                <div class="layui-form-item">
                    <button id="login-btn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="login-submit">登
                        入
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="layui/layui.js"></script>
<script>
    layui.config({
        base: '/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$;
        var form = layui.form;
        form.render();
        form.on('submit(login-submit)', function (obj) {
            $('#login-btn').text('登入中...');
            $.ajax({
                url: '/users/login',
                type: 'POST',
                data: obj.field,
                success: function (result) {
                    if (result.code == 0) {
                        window.location.href = result.data;
                    } else {
                        layer.msg(result.msg);
                    }
                }
            });
            return false;
        });

        $('#forget-password-btn').on('click', function () {
            layer.msg('请联系管理员重置密码');
        });

        $('#LAY-user-login-username').focus();
    });
</script>

</body>
</html>
